﻿/**********************************************************/
/*** 本类是用于快速创建和发布事件，也可用来当作特定事件发布载体***/
/**********************************************************/
package com._public._events
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	/**
	 * 不定向事件管理
	 * @author WZH(shch8.com)
	 * 2009-6-3 14:32
	 * @example 
	 * 	CallEvent.getInstance().createEvent("test", fun);
		CallEvent.getInstance().dispatch("test",{a:5,b:6})
		function fun(event:Object):void {
			trace(event.value.a)
			}
	 */
	 
	public class CallEvent extends EventDispatcher
	{
		private static var Instance:CallEvent = new CallEvent;
		public static function getInstance():CallEvent {
			return Instance;
		}
		/**创建新事件
		 * @param EventName				<String> 事件名
		 * @param callFun				<Function> 事件执行函数
		 * @return void
		 * */
		public function createEvent(EventName:String,callFun:Function):void {
			addEventListener(EventName, callFun);
			}
		/**发布事件
		 * @param EventName				<String> 事件名
		 * @param value					<Object> 事件参数值
		 * @return void
		 * */
		public function dispatch(EventName:String,value:Object):void {
			dispatchEvent(new RunEvent(EventName,value));
			}
	}
	
}
import flash.events.Event;
class RunEvent extends Event {
		public static var COMPLETE : String = "complete";
		private var obj:Object;
		public function RunEvent(type:String,_obj:Object=null,bubbles:Boolean=false, cancelable:Boolean=false) 
		{ 
			super(type);
			obj = _obj;
		} 
		public function get value():Object {
			return obj;
			}
		public override function clone():Event 
		{ 
			return new RunEvent(type);
		} 
		
	}